package com.rc.web.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.rc.pojo.dto.dto.AiChatDTO;
import com.rc.pojo.po.AiChat;
import com.rc.pojo.vo.aichat.AiChatVO;
import com.rc.web.converter.AiChatConverter;
import com.rc.web.mapper.AiChatMapper;
import com.rc.web.service.AiChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AI聊天服务实现类
 * 提供AI聊天相关的业务逻辑实现
 */
@Service
@RequiredArgsConstructor
public class AiChatServiceImpl extends ServiceImpl<AiChatMapper, AiChat> implements AiChatService {
    // AI聊天转换器
    private final AiChatConverter aiChatConverter;

    /**
     * 获取AI聊天记录列表
     * @return AI聊天记录VO列表
     */
    @Override
    public List<AiChatVO> getList() {
        List<AiChat> aiChats = this.list();
        return aiChats.stream()
                .map(aiChatConverter::toVO)
                .toList();
    }

    /**
     * 批量添加AI聊天记录
     * @param dtoList AI聊天记录DTO列表
     */
    @Override
    public void addBatch(List<AiChatDTO> dtoList) {
        List<AiChat> list = dtoList.stream()
                .map(aiChatConverter::dto2PO)
                .toList();
        this.saveBatch(list);
    }
}
